<?php
/**
 * --------------------------------------------------------------
 * 公共类
 * Author: zd <kfzphp@126.com>
 * Date: 2018-06-01
 * Project: kfzphp.com
 * --------------------------------------------------------------
 */

if(APP_DEBUG) {
    ini_set("display_errors", "On");
    error_reporting(E_ALL);
}

class KfzTools
{
    /**
     * 调用静态方法时，不会执行构造方法，只有实例化对象时才会触发构造函数
     */
    public function __construct()
    {

    }

    /**
     * 文件上传
     * @return [type]     [上传成功状态为1，返回文件路径]
     */
    public static function upload()
    {
        if (!empty($_FILES)) {
            require MASTER_PATH . '/KfzUpload.class.php';
            $upload = new KfzUpload($config);
            return $upload->upload();
        }
        return false;
    }

    /**
     * 发送短信
     * @param  string     $data [发送参数]
     * @return [type]           [true 发送成功 false 发送失败]
     */
    public static function sendsms($data = '')
    {
        if($data) {
            set_time_limit(0);
            header('Content-Type: text/plain; charset=utf-8');
            $version = $this->config['SMS_VERSION'];
            if(!in_array($version, [2016, 2017])) {
                return false;
            }
            // 引入短信类
            require MASTER_PATH . '/KfzAlidayu' . $version . '.class.php';
            $dayu = new KfzAlidayu($data);
            return $dayu->sendSms();
        }
        return false;
    }


}